/**
 * output package name
 */
package com.kingdee.eas.custom.hr.compensation.client;


import org.apache.log4j.Logger;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.custom.hr.compensation.AllowanceTreeFactory;
import com.kingdee.eas.custom.hr.compensation.AllowanceTreeInfo;
import com.kingdee.eas.framework.*;
import com.kingdee.util.StringUtils;
import com.kingdee.eas.basedata.org.OrgBlankException;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.MsgBox;
import com.kingdee.eas.util.client.EASResource;
import java.awt.event.ActionEvent;


/**
 * output class name
 */
public class AllowanceTreeEditUI extends AbstractAllowanceTreeEditUI
{
    private static final Logger logger = CoreUIObject.getLogger(AllowanceTreeEditUI.class);
    
    /**
     * output class constructor
     */
    public AllowanceTreeEditUI() throws Exception
    {
        super();
        txtNumber.setEditable(false);
        //txtNumber.setEnabled(false);
    }

    /**
     * output getBizInterface method
     */
    protected com.kingdee.eas.framework.ICoreBase getBizInterface() throws Exception
    {
        return com.kingdee.eas.custom.hr.compensation.AllowanceTreeFactory.getRemoteInstance();
    }

    /**
     * output createNewData method
     */
    protected com.kingdee.bos.dao.IObjectValue createNewData()
    {
        com.kingdee.eas.custom.hr.compensation.AllowanceTreeInfo objectValue = new com.kingdee.eas.custom.hr.compensation.AllowanceTreeInfo();
        objectValue.setParent((AllowanceTreeInfo)getUIContext().get("ParentNode"));
        return objectValue;

    }

    protected void verifyInput(ActionEvent e)
    throws Exception
	{
	    if(StringUtils.isEmpty(editData.getNumber()))
	    {
	        txtNumber.requestFocusInWindow();
	        throw new OrgBlankException(OrgBlankException.NUMBER_CAN_NOT_BLANK);
	    }
	    if(StringUtils.isEmpty(editData.getName()))
	    {
	        txtName.requestFocusInWindow();
	        throw new OrgBlankException(OrgBlankException.NAME_CAN_NOT_BLANK);
	    }
	    if(OprtState.ADDNEW.equals(getOprtState()))
	    {
	        if(AllowanceTreeFactory.getRemoteInstance().exists("where number='" + editData.getNumber() + "'"))
	            throw new TreeBaseException(TreeBaseException.CHECKNUMBERDUPLICATED, new Object[] {
	                editData.getNumber()
	            });
	        if(AllowanceTreeFactory.getRemoteInstance().exists("where name='" + editData.getName() + "'"))
	        {
	            MsgBox.showError(EASResource.getString("com.kingdee.eas.basedata.hraux.HRAUXAutoGenerateResource", "0_DimpolmaTypeEditUI") + editData.getName() + EASResource.getString("com.kingdee.eas.basedata.hraux.HRAUXAutoGenerateResource", "1_DimpolmaTypeEditUI"));
	            SysUtil.abort();
	        }
	    }
	}

	public SelectorItemCollection getSelectors()
	{
	    SelectorItemCollection sic = super.getSelectors();
	    sic.add(new SelectorItemInfo("parent.id"));
	    return sic;
	}

	public void actionCopy_actionPerformed(ActionEvent e)
	    throws Exception
	{
	    super.actionCopy_actionPerformed(e);
	    txtNumber.setText("");
	}

	
}